import { notFound } from "next/navigation"; import type { ReactNode } from "react"; import { api } from "@/lib/api"; import { countryBySlug, COUNTRIES } from "@websensor/core/client"; /** * Existence check outside the `loading.tsx` boundary so unknown country slugs return a real 404 instead of a * 200 shell followed by the not-found UI (the page's own call is deduplicated by fetch memoization). */ export default async function CountryLayout({ params, children }: { params: Promise<{ slug: string }>; children: ReactNode }) { const { slug } = await params; if (!countryBySlug(slug) && !COUNTRIES[slug.toUpperCase()]) notFound(); if (!(await api.country(slug))) notFound(); return children; }